package com.yanqu.road.server.manger.activity.flowercard;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.flowercards.config.FlowerCardRoundInfo;
import com.yanqu.road.entity.activity.flowercards.config.FlowerCardScoreInfo;
import com.yanqu.road.entity.activity.flowercards.config.FlowerCardSkillInfo;
import com.yanqu.road.entity.config.goods.GoodsInfo;
import com.yanqu.road.entity.enums.eItemId;
import com.yanqu.road.server.manger.config.GoodsMgr;
import com.yanqu.road.utils.string.StringUtils;

import java.util.List;

public class FlowerCardsConfig {

    private ActivityInfo activityInfo;


    public FlowerCardsConfig(ActivityInfo activityInfo) {
        this.activityInfo = activityInfo;
    }

    public ActivityInfo getActivityInfo() {
        return activityInfo;
    }

    /**
     * 花牌之恋积分ID
     */
    private int scoreItemId;

    /**
     * 体力道具—花夹ID
     */
    private int energyItemId;

    /**
     * 体力重置时间/s
     */
    private int energyResetTime;

    /**
     * 体力重置恢复值
     */
    private int energyResetNum;

    /**
     * 轮次配置
     */
    private List<FlowerCardRoundInfo> roundList;

    /**
     * 评价配置
     */
    private List<FlowerCardScoreInfo> scoreInfoList;

    /**
     * 技能配置
     */
    private List<FlowerCardSkillInfo> skillInfoList;

    /**
     * 技能重置的元宝消耗（配置：初始值|加成值|最大值）初始值+(重置次数-1)×加成值
     */
    private String skillResetConsume;

    /**
     * 消除基础积分
     */
    private int scoreBase;

    /**
     * 连消积分加成（连消次数，连消加成）连消基础分×连消加成
     */
    private String scoreContAdd;

    /**
     * 卡牌基础良缘值
     */
    private int marriageBase;

    /**
     * 白银战令特权（美女耐心值上限+2）
     */
    private List<Integer> sufferanceAdd;

    /**
     * 黄金战令特权（卡牌基础良缘值提升固定值）
     */
    private List<Integer> scoreOrderAdd;

    /**
     * 玫瑰花露转换积分
     */
    private int changeScore;


    /**
     * @param round 轮次
     * @param type 0 练习：  1：正式
     */
    public FlowerCardRoundInfo getFlowerCardRoundInfoById(int round, int type){
        for (FlowerCardRoundInfo roundInfo : roundList) {
            if(round == roundInfo.getRounds() && type == roundInfo.getType()){
                return roundInfo;
            }
        }
        return null;
    }

    public FlowerCardSkillInfo getFlowerCardSkillInfo(int skillId, int skillLv){
        for (FlowerCardSkillInfo skillInfo : skillInfoList) {
            if(skillInfo.getSkillId() == skillId && skillInfo.getSkillLevel() == skillLv){
                return skillInfo;
            }
        }
        return null;
    }

    public int getSkillMaxLv(int skill){
        int max = 0;
        for (FlowerCardSkillInfo skillInfo : skillInfoList) {
            if(skillInfo.getSkillId() == skill && skillInfo.getSkillLevel() > max){
                max = skillInfo.getSkillLevel();
            }
        }
        return max;
    }

    public FlowerCardScoreInfo getFlowerCardScoreInfo(int score){
        FlowerCardScoreInfo scoreInfo = null;
        for (FlowerCardScoreInfo info : scoreInfoList) {
            List<Integer> rangeList = StringUtils.stringToIntegerList(info.getScore(), ";");
            if(score >= rangeList.get(0)){
                scoreInfo = info;
            }
        }
        return scoreInfo;
    }

    public int getComboAddition(int combo){
        int addition = 1000;
        List<String> paramList = StringUtils.stringToStringList(this.scoreContAdd, "\\|");
        for (String param : paramList) {
            List<Integer> list = StringUtils.stringToIntegerList(param, ",");
            if(combo >= list.get(0)){
                addition = list.get(1);
            }
        }
        return addition;
    }


    public void setActivityInfo(ActivityInfo activityInfo) {
        this.activityInfo = activityInfo;
    }

    public int getScoreItemId() {
        return scoreItemId;
    }

    public void setScoreItemId(int scoreItemId) {
        this.scoreItemId = scoreItemId;
    }

    public int getEnergyItemId() {
        return energyItemId;
    }

    public void setEnergyItemId(int energyItemId) {
        this.energyItemId = energyItemId;
    }

    public int getEnergyResetTime() {
        return energyResetTime;
    }

    public void setEnergyResetTime(int energyResetTime) {
        this.energyResetTime = energyResetTime;
    }

    public int getEnergyResetNum() {
        return energyResetNum;
    }

    public void setEnergyResetNum(int energyResetNum) {
        this.energyResetNum = energyResetNum;
    }

    public List<FlowerCardRoundInfo> getRoundList() {
        return roundList;
    }

    public void setRoundList(List<FlowerCardRoundInfo> roundList) {
        this.roundList = roundList;
    }

    public List<FlowerCardScoreInfo> getScoreInfoList() {
        return scoreInfoList;
    }

    public void setScoreInfoList(List<FlowerCardScoreInfo> scoreInfoList) {
        this.scoreInfoList = scoreInfoList;
    }

    public List<FlowerCardSkillInfo> getSkillInfoList() {
        return skillInfoList;
    }

    public void setSkillInfoList(List<FlowerCardSkillInfo> skillInfoList) {
        this.skillInfoList = skillInfoList;
    }

    public String getSkillResetConsume() {
        return skillResetConsume;
    }

    public void setSkillResetConsume(String skillResetConsume) {
        this.skillResetConsume = skillResetConsume;
    }

    public int getScoreBase() {
        return scoreBase;
    }

    public void setScoreBase(int scoreBase) {
        this.scoreBase = scoreBase;
    }

    public String getScoreContAdd() {
        return scoreContAdd;
    }

    public void setScoreContAdd(String scoreContAdd) {
        this.scoreContAdd = scoreContAdd;
    }

    public int getMarriageBase() {
        return marriageBase;
    }

    public void setMarriageBase(int marriageBase) {
        this.marriageBase = marriageBase;
    }

    public List<Integer> getSufferanceAdd() {
        GoodsInfo goodsInfo = GoodsMgr.getGoodsById(eItemId.FlowerCardSilver.getValue());
        if(goodsInfo != null){
            return StringUtils.stringToIntegerList(goodsInfo.getParamStr(), "\\|");
        }
        return sufferanceAdd;
    }

    public void setSufferanceAdd(List<Integer> sufferanceAdd) {
        this.sufferanceAdd = sufferanceAdd;
    }

    public List<Integer> getScoreOrderAdd() {
        GoodsInfo goodsInfo = GoodsMgr.getGoodsById(eItemId.FlowerCardGold.getValue());
        if(goodsInfo != null){
            return StringUtils.stringToIntegerList(goodsInfo.getParamStr(), "\\|");
        }
        return scoreOrderAdd;
    }

    public void setScoreOrderAdd(List<Integer> scoreOrderAdd) {
        this.scoreOrderAdd = scoreOrderAdd;
    }

    public int getChangeScore() {
        return changeScore;
    }

    public void setChangeScore(int changeScore) {
        this.changeScore = changeScore;
    }
}
